"""
请求百度翻译 详细翻译
"""
import urllib.request
import urllib.parse
import json

url = "https://fanyi.baidu.com/v2transapi?from=en&to=zh"
form_data = {
    "from": "en",
    "to": "zh",
    "query": "hello",
    "transtype": "realtime",
    "simple_means_flag": "3",
    "sign": "54706.276099",
    "token": "bdc99ed773c1f3110f3624b5aeb0d049",
    "domain": "common"
}
data = urllib.parse.urlencode(form_data).encode("utf-8")
headers = {
    "Cookie": "BIDUPSID=54B8FD7F6DD85410855AD1986E0D2A1B; PSTM=1658475933; BAIDUID=54B8FD7F6DD85410C37C4E9AD3E52166:FG=1; BAIDUID_BFESS=54B8FD7F6DD85410C37C4E9AD3E52166:FG=1; ZFY=bamukTd4yw2HefvCqjq6oFvDlatE3tSEJ:A9iwTWCdtw:C; H_PS_PSSID=36560_37354_37300_37486_36805_36786_37540_37482_37500_26350_37285; BA_HECTOR=84a0842h0g00a50l8h0k8hlh1hki5f31a; delPer=0; PSINO=5; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1665734127; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1665734127; APPGUIDE_10_0_2=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; ab_sr=1.0.1_MTk4NDVhYzg1OTQ1MTc4ZmUwNTA3YzVmZjFiNGEyYTM3NjYxMjQwNGRkOWZiMmQ0ZDc5Y2Y1NGU4YWFhOWUxMjIwNjYxZDIyZmYzMWVkZjgxYmU0MWVhNzFkNjlhNDZlZjVmYmI5ZTQ4MzlmZDJlZTExODFhNGY4ZTU0ZDUyNDRjZjEzZTJkZWIyMDBkZTI1M2ViYWJjNGVmOTZlMDc5ZQ=="
}

req = urllib.request.Request(url=url, data=data, headers=headers)
response = urllib.request.urlopen(req)
content = response.read().decode("utf-8")
obj = json.loads(content)
print(obj)
